package acm;

import java.util.Scanner;

public class P0505 {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        int sum=1;
        for (int i=2;i<=n;i++){
            sum=sum*i;
            while (sum%10==0){
                sum=sum/10;
            }
            sum %= 1000;
        }
        int yu;
        yu=sum%10;
        System.out.print(yu);
    }
}
